	/*
	* @Author: long-xinyu2 2192763423@qq.com
	* @Date: 2025-04-01 10:09:57
	* @LastEditors: long-xinyu2 2192763423@qq.com
	* @LastEditTime: 2025-04-21 11:35:28
	* @FilePath: \algorithm\algorithm-training\lqb\acwing4_1.cpp
	* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
	*/
	#include<iostream>
	#include<cstring>
	#include<vector>
	#include<map>
	#include<cstdio>
	#include<algorithm>
	#include<string>
	#include<string.h>
	#include<queue>
	#include<math.h>
	#include<set>
	#include<functional>
	#include <bitset>
	using namespace std;
	using ull = unsigned long long;
	using i128 = __int128_t;
	//inline int inc(int x,int v,int mod){x+=v;return x>=mod?x-mod:x;}//代替取模+
	#define endl '\n'
	typedef long long LL;
	typedef unsigned long long ULL;
	typedef pair<int,int> PII;
	#define int long long

	const int N = 1010;

	int f[N];

	// 求x, y，使得ax + by = gcd(a, b)
	int exgcd(int a, int b, int &x, int &y)
	{
		if (!b)
		{
			x = 1; y = 0;
			return a;   //到达递归边界开始向上一层返回
		}
		int d = exgcd(b, a % b, x, y);
		int temp=y;    //推出这一层的x，y
		y=x-(a/b)*y;
		x=temp;
		return d;
	}

	void solve()
	{  
		int x1,y1,x2,y2;
		cin >> x1 >> y1 >> x2 >> y2;
		if(abs(__gcd(x1,x2)) == 1 && abs(__gcd(y1,y2)) == 1)
		{
			int ans1,ans2;
			int uu = exgcd(x1,x2,ans1,ans2);
			int cnt = 0;
			if(ans2 <= 0) ans2 += y1;
			if(y2 % y1 == 0 || __gcd(x1,y1) % ans2 == 0)
			{	
				cnt ++;
			}
			uu = exgcd(y1,y2,ans1,ans2);
			if(ans2 <= 0) ans2 += y1;
			if(x2 % x1 == 0 || __gcd(x1,y1) % ans2 == 0)
			{
				cnt ++;
			}
			if(cnt == 2) cout << "YES" << endl;
			else cout << "NO" << endl;
		}
		else cout << "NO" << endl;
	}
	signed main()
	{
		int t = 1;
		cin >> t;
		while(t --)
		{
			solve();
		}
	}
